Skip to content

Conversation

@NVSRahul
Copy link
Contributor

Fix uuidgen(1) to generate UUIDs in bounded batches that respect the
kernel uuidgen(2) limit.

The kernel uuidgen(2) system call is limited to 2048 UUIDs per call, but
uuidgen(1) attempted to generate arbitrarily many UUIDs in a single
invocation and allocate memory proportional to the request size. This
can lead to kernel errors, unnecessary memory usage, and potential
size_t overflow.

This change generates UUIDs in fixed-size batches, preserving streaming
semantics while respecting the kernel ABI and avoiding unbounded memory
allocation.

Copilot AI review requested due to automatic review settings January 13, 2026 10:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Jan 13, 2026

Thank you for taking the time to contribute to FreeBSD!

All issues resolved.

@NVSRahul NVSRahul force-pushed the uuidgen-batch-fix branch 2 times, most recently from b406ddf to 6e48b12 Compare January 13, 2026 10:25
@NVSRahul NVSRahul requested a review from Copilot January 13, 2026 10:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NVSRahul
Copy link
Contributor Author

Hello,

All the CI checks are completed (or in progress for internal CI).

Just double-checking if there’s anything else that I should adjust or work on regarding this change.

Thanks for your time.

@NVSRahul NVSRahul force-pushed the uuidgen-batch-fix branch 2 times, most recently from ac95ee2 to 47696d8 Compare January 18, 2026 03:46
Copy link
Member

@bsdimp bsdimp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2048 being hard coded seems weird, but I don't see a #define or sysctl to get this value.

The uuidgen(2) system call enforces a hard upper limit of 2048 UUIDs per
invocation. uuidgen(1) previously attempted to generate arbitrary counts
in a single call and allocated memory accordingly, leading to EINVAL
errors, unnecessary memory usage, and potential overflow risks.

Generate UUIDs in fixed-size batches, streaming output incrementally
while preserving existing semantics. Mirror the kernel limit explicitly
since it is not exposed via a public interface.

Signed-off-by: NVSRahul <[email protected]>
@NVSRahul
Copy link
Contributor Author

Thanks for the review!

I agree the hard-coded limit looks odd. Since the uuidgen(2) limit is enforced in the kernel and not exposed via a sysctl or public header, I’ve renamed the constant to UUIDGEN_BATCH_MAX and added a comment pointing directly to sys/kern/kern_uuid.c to document the origin and rationale.

Please let me know if you’d prefer this handled differently.

@NVSRahul NVSRahul requested a review from bsdimp January 29, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants